home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Plug-In Power Pack for Netscape Communicator
/
Plug-In Power Pack for Netscape Communicator.iso
/
plugins
/
dataviews
/
dvtools
/
demos
/
telecomdemo
/
status.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-05-08
|
11KB
|
370 lines
#ifndef lint
static char SccsId[]= "@(#)status.c V1.10 3/17/95";
#endif
/*
| File name: status.c
|========================================================================
|
| Copyright (c) 1990 -- V.I. Corporation
|
|========================================================================
*/
#include "simulate.h"
#include "tlc_fundecl.h"
/*
* Define the normal input mask for this screen.
*/
#define NORMAL_MASK ( (ULONG) V_BUTTONPRESS | V_BUTTONRELEASE | V_KEYPRESS | \
V_WINDOW_QUIT | V_EXPOSE | V_RESIZE )
#define DEF_COLORTABLE (ADDRESS)NULL
/***************** Begin Function Declarations *************/
LOCAL void ResizeStatusScreen V_P_((void));
LOCAL void PickInTopLevelDrawport V_P_((OBJECT location));
LOCAL BOOLPARAM ValidNodeName V_P_((char *name, NODE_STRUCT **node_struct, VIEW_STRUCT **view_struct));
LOCAL void HandleSubDrawportInput V_P_((OBJECT location));
LOCAL BOOLPARAM ValidPartName V_P_((char *name, PART_STRUCT **part_struct, char **part_type));
/***************** End Function Declarations *************/
/*
* CreateStatusScreen -- create the status screen and setup the event mask.
*/
void
CreateStatusScreen (devname)
char *devname;
{
int error_code;
char buf[50];
StatusScreen = TscOpenSet (devname, DEF_COLORTABLE,
#ifdef WINNT
V_WIN32_ICON_NAME, "teleicon",
V_WINDOW_HEIGHT, 414,
V_WINDOW_WIDTH, 552,
V_WINDOW_X, 240,
V_WINDOW_Y, 0,
#ifdef DOUBLE_BUFFER
V_WIN32_DOUBLE_BUFFER, YES,
#endif /* DOUBLE_BUFFER */
#else /* Not WINNT */
V_WINDOW_HEIGHT, 650,
V_WINDOW_WIDTH, 650,
V_WINDOW_X, 450,
V_WINDOW_Y, 0,
V_X_EXPOSURE_BLOCK, YES,
#endif /* WINNT */
V_WINDOW_NAME, "Network Status",
V_INITIAL_CURSOR,
V_END_OF_LIST );
if(!StatusScreen)
{
error_code=TscOpenError();
#ifdef WINNT
sprintf(buf,"Product is not validated. Error code %d.",error_code);
MessageBox(NULL,buf,"Validation Error",MB_OK);
#else
fprintf(stderr,"Product is not validated. Error code %d.",error_code);
#endif
exit(error_code);
}
(VOID) VOscWinEventMask ((ULONG) NORMAL_MASK, 0L);
}
/*
* LoadAuxStatusViews -- load the other subdrawport views.
*/
void LoadAuxStatusViews
V_P_ ((void))
{
LoadDialogView (DialogViewName);
LoadFixboxView (FixboxViewName);
LoadSmallmapView (SmallmapViewName);
}
/*
* DestroyStatusScreen -- called at program termination. Destroy all
* drawports associated with this screen, then close the window.
*/
void DestroyStatusScreen
V_P_ ((void))
{
(VOID) TscSetCurrentScreen (StatusScreen);
(VOID) TdpDestroy (Dialog.disp_info.drawport);
(VOID) TdpDestroy (Fixbox.disp_info.drawport);
(VOID) TdpDestroy (Smallmap.disp_info.drawport);
DestroyStatusDrawports ();
(VOID) TscClose (StatusScreen);
}
/*
* UpdateStatusScreen -- update the dynamic components of the main status
* view and also of the subviews that are visible.
*/
void UpdateStatusScreen
V_P_ ((void))
{
(VOID) TdpDrawNext (SimParams.curr_view->drawport);
if (Dialog.disp_info.drawn)
UpdateDialogDrawport ();
if (Smallmap.disp_info.drawn)
(VOID) TdpDrawNext (Smallmap.disp_info.drawport);
}
/*
* HandleStatusInput -- deal with input to the status window. Deal with
* window events and picks in the main drawport here. If the input is
* in one of the subviews, call the correct input handling routine for
* that drawport.
*/
void
HandleStatusInput (location)
OBJECT location;
{
DRAWPORT drawport;
INT button_num;
switch (VOloType (location))
{
/*
* Deal with window system events.
*/
case V_EXPOSE:
ExposeViews (location);
break;
case V_RESIZE:
ResizeStatusScreen ();
break;
case V_WINDOW_QUIT:
*Control.quit_flag = 1;
break;
/*
* We're only interested in keypresses if they're going into
* the fixbox subview.
*/
case V_KEYPRESS:
if (TloGetSelectedDrawport (location) == Fixbox.disp_info.drawport)
InputInFixboxDrawport (location);
break;
case V_BUTTONPRESS:
button_num = VOloButton (location);
drawport = TloGetSelectedDrawport (location);
/*
* If it's a first button, then determine which drawport the
* pick happened in and call the correct routine.
*/
if (button_num == 1)
{
if (drawport == SimParams.top_view->drawport)
PickInTopLevelDrawport (location);
else if (drawport == Dialog.disp_info.drawport)
PickInDialogDrawport (location);
else if (drawport == Fixbox.disp_info.drawport)
InputInFixboxDrawport (location);
else if (drawport == Smallmap.disp_info.drawport)
InputInSmallmapDrawport (location);
else
HandleSubDrawportInput (location);
}
/*
* If it's a second or third button and the drawport is one of the
* subviews, we're moving that subview to a new screen location.
* Call the correct drawport moving routine.
*/
else if (button_num == 2 || button_num == 3)
if (drawport == Dialog.disp_info.drawport)
{
MoveDialogDrawport (location);
(VOID) VOscWinEventMask ((ULONG) NORMAL_MASK, 0L);
}
else if (drawport == Fixbox.disp_info.drawport)
{
MoveFixboxDrawport (location);
(VOID) VOscWinEventMask ((ULONG) NORMAL_MASK, 0L);
}
else if (drawport == Smallmap.disp_info.drawport)
{
MoveSmallmapDrawport (location);
(VOID) VOscWinEventMask ((ULONG) NORMAL_MASK, 0L);
}
break;
case V_BUTTONRELEASE:
(VOID) VUerHandleLocEvent (location);
break;
default:
break;
}
}
/*
* ResizeStatusScreen -- handle a resize window event.
* Reset the screen and recreate the
* subview's drawports at the correct position based on their
* virtual coordinates.
*/
LOCAL void ResizeStatusScreen
V_P_ ((void))
{
(VOID) TscReset (StatusScreen);
RecreateDrawport (&Dialog.disp_info);
RecreateDrawport (&Smallmap.disp_info);
RecreateDrawport (&Fixbox.disp_info);
}
/*
* PickInTopLevelDrawport -- handle a pick in the top level drawport. If
* the selected object's name corresponds to a network node we have
* knowledge of, bring up the dialog subview with that node's information.
*/
LOCAL void
PickInTopLevelDrawport (location)
OBJECT location;
{
CHAR *name;
NODE_STRUCT *node_struct;
VIEW_STRUCT *view_struct;
if ((name = TloGetSelectedObjectName (location)))
if (ValidNodeName (name, &node_struct, &view_struct))
{
SetupDialogBox (node_struct, view_struct);
DrawSubView (&Dialog.disp_info);
}
else if (strcmp (name, "Quit") == 0)
{
*Control.quit_flag = 1;
(VOID) VUerHandleLocEvent (location);
}
}
/*
* ValidNodeName -- see if an object's name is a correct description of a
* known node. Get the node name part and look in the symbol table for it.
* If there's a view name attached, see if we know about that view and
* return the infomation.
*/
LOCAL BOOLPARAM
ValidNodeName (name, node_struct, view_struct)
char *name;
NODE_STRUCT **node_struct;
VIEW_STRUCT **view_struct;
{
CHAR *ptr, *next_tok, *node_name, *view_name;
ptr = StrClone (name);
get_token (ptr, &ptr, &next_tok);
if (next_tok == NULL)
return NO;
get_token (next_tok, &node_name, &next_tok);
if ((*node_struct = GetNamedNode (node_name)))
{
if (next_tok != NULL)
{
get_token (next_tok, &view_name, &next_tok);
*view_struct = GetNamedView (view_name);
if (*view_struct)
return YES;
}
else
*view_struct = NULL;
}
return NO;
}
/*
* HandleSubDrawportInput -- handle input in one of the non-top level main
* drawports. If the selected object is a part or switch, bring up the
* fixbox for the user to look at. If it's name is Smallmap then draw the
* smallmap subview if it's not already drawn. If the name indicates
* another main drawport, draw that new main view.
*/
LOCAL void
HandleSubDrawportInput (location)
OBJECT location;
{
CHAR *name, *cptr;
VIEW_STRUCT *view_struct;
PART_STRUCT *part_struct;
CHAR *part_type;
(VOID) VUerHandleLocEvent (location);
if ((name = TloGetSelectedObjectName (location)))
if (strncmp (name, "part", 4) == 0 || strncmp (name, "switch", 5) == 0)
{
if (ValidPartName (name, &part_struct, &part_type))
{
SetupFixbox (part_struct, part_type);
DrawSubView (&Fixbox.disp_info);
}
}
else if (strcmp (name, "Quit") == 0)
{
*Control.quit_flag = 1;
}
else if (strcmp (name, "Smallmap") == 0)
{
if (Smallmap.disp_info.drawn == NO)
DrawSubView (&Smallmap.disp_info);
else
EraseSubView (&Smallmap.disp_info, NULL);
}
else if ((cptr = S_STR_RINDEX (name, '*')))
if ((view_struct = GetNamedView (cptr + 1)))
NewMainView (SimParams.curr_view, view_struct);
}
/*
* ValidPartName -- check an object's name to see if it's a part (or
* switch) that we know about. If so, then return the information.
*/
LOCAL BOOLPARAM
ValidPartName (name, part_struct, part_type)
char *name;
PART_STRUCT **part_struct;
char **part_type;
{
CHAR *ptr, *next_tok, *type, *part_name, *view_name;
CHAR tmp_str[30];
ptr = StrClone (name);
get_token (ptr, &type, &next_tok);
if (next_tok == NULL)
return NO;
get_token (next_tok, &part_name, &next_tok);
if (strcmp (type, "part") == 0)
{
view_name = SimParams.curr_view->view_name;
(VOID) sprintf (tmp_str, "%s*%s", view_name, part_name);
}
else if (strcmp (type, "switch") == 0)
(VOID) sprintf (tmp_str, "switch*%s", part_name);
else
return NO;
if ((*part_struct = GetNamedPart (tmp_str)))
if ((*part_struct)->status != NORMAL)
{
if (strcmp (type, "part") == 0)
*part_type = part_name;
else
*part_type = type;
return YES;
}
return NO;
}